<template>
    <div v-if="tkIsShow">
        <div class="zhezhao"></div>
        <div class="tankuang">
            <div class="tk_title">{{ title }}</div>
            <img src="../../assets/icon-close.png" class="tk_close" @click="closeTk">
            <div class="tk_content">
                <div class="tk_form">
                    <el-form :model="form" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                        <el-form-item label="积分数量" prop="point">
                            <el-input type="number" v-model="form.point" size="small"></el-input>
                        </el-form-item>
                        <el-form-item label="金额" prop="money">
                            <el-input type="number" v-model="form.money" size="small"></el-input>
                        </el-form-item>
                        <el-form-item label="有效期" prop="qixian">
                            <el-date-picker
                                v-model="form.qixian"
                                type="date"
                                placeholder="选择日期"
                                value-format="yyyy-MM-dd"
                                style="width: 100%;">
                            </el-date-picker>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="submitForm('ruleForm')" size="small">确定</el-button>
                            <el-button @click="resetForm('ruleForm')" size="small">重置</el-button>
                        </el-form-item>
                    </el-form>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
export default {
  data() {
    return {
        tkIsShow:false,
        title:"",
        form:{
            point:'',
            money:'',
            qixian:'2999-12-31'
        },
        rules: {
            point: [
                {required: true,message: "请输入充值积分数量",trigger: ["blur,change"]}
            ],
            money: [
                {required: true,message: "请输入充值金额",trigger: ["blur,change"]}
            ],
            qixian: [
                {required: true,message: "请选择有效期限",trigger: ["blur,change"]}
            ]
        },
        uuid:0
    };
  },
  methods: {
    __init(uuid) { 
        this.uuid=uuid;
    },
    submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            var url="manager/addPointByUUID";
            var params={
                ...this.form,
                uuid:this.uuid,
                type:1
            }
            this.$post(url, params).then((res) => {
                console.log(res)
                if (res.code === 200) {
                    this.$message.success("操作成功")
                    this.closeTk();
                } else {
                    this.$message.error(res.msg)
                }
            });
          } else {
            console.log('error submit!!');
            return false;
          }
        });
    },
    resetForm(formName) {
        this.$refs[formName].resetFields();
    },
    closeTk(){
        this.tkIsShow = false;
        this.$emit("close");
    }
  }
}
</script>
<style scoped lang="scss">
  .zhezhao{
    position: fixed;
    width: 100%;
    height: 100%;
    background-color: #000;
    opacity: 0.6;
    top: 0;
    left: 0;
    z-index: 200;
  }
  .tankuang{
    position: fixed;
    width: 30%;
    background-color: #fff;
    top: 15%;
    left: 32%;
    z-index: 201;
    height: 40%;
    border-radius: 5px;
  }
  .tk_title{
    font-size: 17px;
    height: 25px;
    line-height: 25px;
    margin: 15px 0;
  }
  .tk_content{
    width: 100%;
    height: calc(100% - 100px);
    overflow-y: auto;
    &::-webkit-scrollbar {
        width: 8px; /* 设置滚动条宽度为8像素 */
        background-color: transparent;
      }
      /* 滑块样式 */
      &::-webkit-scrollbar-thumb {
        background-color: #1e4dc6; /* 设置滑块颜色为深灰色 */
        border-radius: 4px; /* 设置滑块边角半径为4像素 */
      }
      /* 滚动条轨道内部空白区域样式 */
      &::-webkit-scrollbar-track {
        background-color: #fff /* 设置轨道背景色为浅灰色 */
      }

      /* 滚动条两端按钮样式 */
      &::-webkit-scrollbar-button {
        display: none; /* 不显示按钮 */
      }

      /* 交叉点处的区域样式 */
      &::-webkit-scrollbar-corner {
        background-color: transparent; /* 设置交叉点处的背景色为透明 */
      }

      /* 调整大小手柄样式 */
      &::-webkit-resizer {
        display: none; /* 不显示调整大小手柄 */
      }
  }
  .tk_form{
    width: 80%;
    margin-left: 10%;
    height: 100%;
  }
  .tk_close{
    position: absolute;
    width: 16px;
    height: 16px;
    top: 18px;
    right: 20px;
  }
  ::v-deep .el-select>.el-input{
    width: 310px !important;
  }
  ::v-depp .el-date-editor.el-input{
    width: 310px !important;
  }
</style>
